package net.jiastudy.biz.sys.util;

import net.jiastudy.biz.sys.entity.Dict;
import net.jiastudy.biz.sys.service.DictService;
import net.jiastudy.core.utils.SpringUtility;

public class DictUtils {
	private static DictService dictService = SpringUtility.getBean(DictService.class);

	public static Dict getDict(String groupCode, String dictKey) {
		return dictService.getDictByGroupCodeAndKey(groupCode, dictKey);
	}

	public static String getDictValue(DictGroup dictGroup, String dictKey) {
		if (null == dictGroup || null == dictKey) {
			return null;
		}
		Dict dict = getDict(dictGroup.name(), dictKey);
		if (dict != null) {
			return dict.getDictValue();
		}
		return null;
	}

	public static String getDictValue(String dictGroup, String dictKey) {
		if (null == dictGroup || null == dictKey) {
			return null;
		}
		Dict dict = getDict(dictGroup, dictKey);
		if (dict != null) {
			return dict.getDictValue();
		}
		return null;
	}
}
